<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import equipmentNoticeservicesLog from '@/api/equipment/equipmentNoticeservicesLog'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  equipmentNoticeservicesLog.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  equipmentNoticeservicesLog.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'flyos_equipment_noticeservices_log',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: equipmentNoticeservicesLog.getList,
  recycleApi: equipmentNoticeservicesLog.getRecycleList,
  add: {
    show: true,
    api: equipmentNoticeservicesLog.save,
    auth: ['equipment:noticeservicesLog:save']
  },
  edit: {
    show: true,
    api: equipmentNoticeservicesLog.update,
    auth: ['equipment:noticeservicesLog:update']
  },
  delete: {
    show: true,
    api: equipmentNoticeservicesLog.deletes,
    auth: ['equipment:noticeservicesLog:delete'],
    realApi: equipmentNoticeservicesLog.realDeletes,
    realAuth: ['equipment:noticeservicesLog:realDeletes']
  },
  recovery: {
    show: true,
    api: equipmentNoticeservicesLog.recoverys,
    auth: ['equipment:noticeservicesLog:recovery']
  },
  import: {
    show: true,
    url: 'equipment/noticeservicesLog/import',
    templateUrl: 'equipment/noticeservicesLog/downloadTemplate',
    auth: ['equipment:noticeservicesLog:import']
  },
  export: {
    show: true,
    url: 'equipment/noticeservicesLog/export',
    auth: ['equipment:noticeservicesLog:export']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入ID"
    }
  },
  {
    title: "标题",
    dataIndex: "vices_id",
    formType: "select",
    search: true
  },
  {
    title: "发送方式",
    dataIndex: "send_type",
    formType: "select",
    search: true,
    dict: {
      name: "send_type",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
    }
  },
  {
    title: "发送状态",
    dataIndex: "send_status",
    formType: "select",
    search: true,
    dict: {
      name: "send_status",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
    }
  },
  {
    title: "发送内容",
    dataIndex: "send_text",
    formType: "textarea",
    search: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "发送时间",
    dataIndex: "created_at",
    formType: "date",
    search: true,
    addDisplay: false,
    editDisplay: false,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  }
])
</script>
<script> export default { name: 'equipment:noticeservicesLog' } </script>